import request from 'utils/request'

// 获取文章列表
export const getArticles = params => {
  return request({
    method: 'get',
    url: '/mp/articles',
    params
  })
}

// 删除文章
export const delArticles = id => {
  return request({
    method: 'DELETE',
    url: '/mp/articles/' + id
  })
}

// 发表文章draft
export const addArticles = (data, draft = false) => {
  return request({
    method: 'POST',
    url: `/mp/articles?draft=${draft}`,
    data
  })
}

// 根据id获取文章列表
export const getArticle = id => {
  return request({
    method: 'get',
    url: '/mp/articles/' + id
  })
}

// 修改文章
export const updataArticles = (data, draft = false) => {
  return request({
    method: 'put',
    url: `/mp/articles/${data.id}?draft=${draft}`,
    data
  })
}
